/*
 * 5.5
 * Write a function to determine the number of bits required to convert integer A to
 * integer B.
 * Input: 31, 14
 * Output: 2
 */
#include <stdio.h>

int checkbits(int a, int b)
{
    int c = a ^ b;
    int n = 0;
    while (c) {
        c &= c - 1;
        n++;
    }
    return n;
}

int main()
{
    int n = checkbits(14, 31);
    printf("%d\n", n);
    return 0;
}
